const sequelize = require('../config/connect.js')//引入数据库连接文件
const config = require('../config/config.js')//引入数据库配置文件
const roomType = require('./roomType.js')//引入房间类型表
const { Op, Model, DataTypes } = require('sequelize')//引入nodejs的orm模型文件

class room extends Model{}  //房间信息表

room.init({
    roomNumber:{
        type:DataTypes.STRING(6),
        primaryKey:true,
        comment:'房间号'
    },
    type:{
        type:DataTypes.STRING(32),
        allowNull:false,
        references:{
            model:roomType,
            key:'type'
        }
    },
    roomStatus:{
        type:DataTypes.ENUM('已入住','未入住'),
        defaultValue:'未入住'
    },
    remarks:{
        type:DataTypes.STRING(32),
        allowNull:false,
        comment:'备注'
    }
},{
    sequelize,
    charset:config.charset,
    timestamps:false,
    freezeTableName:true,
    modelName:'room'
})

module.exports = room;
